<!--<html>-->
<% var now = (new Date()).getTime(); %>
<fieldset>
  <div>
    <legend id="topic">论坛</legend>
  </div>
  <div class="tablebg">
    <div id="pager">
      <%- partial('pager', {page:page, n:n}) %>
      <div class="fr" id="filter">
        <div>
          <% if (user) { %>
          <a href="/addtopic" class="uibtn uibtn-mini">发布话题</a>
          <% } else { %>
          <a href="javascript:;" class="uibtn uibtn-mini checklogin" id="addtopic">发布话题</a>
          <% } %>
        </div>
        <div class="input-prepend">
          <span class="add-on"><i class="icon-search"></i></span>
          <input type="text" id="search" <% if (search) { %>value="<%= search %>"<% } %> title="标题或作者" placeholder=" 标题或作者">
        </div>
        <div>
          <a class="uibtn uibtn-mini" href="javascript:;" id="fil">Filter</a>
        </div>
        <div>
          <a class="uibtn uibtn-mini" href="javascript:;" id="reset">Reset</a>
        </div>
      </div>
    </div>
    <div id="tablediv">
      <table class="table" style="table-layout:fixed;" id="contest">
        <thead>
          <tr>
            <th style="width:60px;"></th>
            <th style="width:100px;">回复/浏览</th>
            <th style="text-align:left;">标题</th>
            <th style="text-align:right;width:160px"></th>
          </tr>
        </thead>
        <tbody>
          <% if (!topics || topics.length == 0) { %>
          <tr class="odd">
            <td class="error-text" colspan="6">No Topics are matched.</td>
          </tr>
          <% } else { %>
          <% topics.forEach(function(p, i){ %>
          <% var img; %>
          <% if (I[p.user]) { %>
          <% img = '/img/avatar/'+p.user+'/4.'+I[p.user]; %>
          <% } else { %>
          <% img = '/img/avatar/%3Ddefault%3D/4.jpeg'; %>
          <% } %>
          <tr>
            <td>
              <a href="/user/<%= p.user %>">
                <img class="img_s topic_img" title="<%= p.user %>" alt="<%= p.user %>" src="<%= img %>" />
              </a>
            </td>
            <td>
              <span class="user-green"><%= p.reviewsQty %></span><span class="user-gray">/<%= p.browseQty %></span>
            </td>
            <td style="text-align:left;" class="ellipsis">
              <% if (user && user.name == 'admin') { %>
                <a class="uibtn" tid="<%= p.id %>" href="javascript:;"><% if (p.top) { %>取消<% } %>置顶</a>
              <% } %>
              <% if (p.top) { %><span class="put_top">置顶</span><% } %>
              <a href="/topic/<%= p.id %>"><%= p.title %></a>
              <% if (now - p.inDate < 86400000) { %>
                <img class="top" src="/img/new.gif" />
              <% } %>
              <% if (p.lastReviewer && now - p.lastReviewTime < 86400000) { %>
                <img class="top" src="/img/hot.gif" />
              <% } %>
            </td>
            <td>
              <% if (p.lastReviewer) { %>
                <% if (I[p.lastReviewer]) { %>
                <% img = '/img/avatar/'+p.lastReviewer+'/4.'+I[p.lastReviewer]; %>
                <% } else { %>
                <% img = '/img/avatar/%3Ddefault%3D/4.jpeg'; %>
                <% } %>
              <a class="topic_timer" href="/topic/<%= p.id %>#<%= p.lastComment %>">
                <img class="img_ss" title="<%= p.lastReviewer %>" alt="<%= p.lastReviewer %>" src="<%= img %>">
                <span><%= getDate(p.lastReviewTime) %></span>
              </a>
              <% } else { %>
              <span class="user-gray fr"><%= getDate(p.lastReviewTime) %></span>
              <% } %>
            </td>
          </tr>
          <% }); %>
          <% } %>
        </tbody>
      </table>
    </div>
  </div>
</fieldset>